home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / Istar.lha / Docs / Using Istar < prev    next >
Encoding:
Text File  |  1997-02-17  |  84.5 KB  |  1,689 lines

  1. USING ISTAR - FOR INFERENCE
  2.  
  3. This is a step-by-step tutorial on how to make good use of Istar, and we 
  4. start by looking at how to make use of inference.  We take real life kinds 
  5. of tasks you might want to use it for and guide you in building knowledge 
  6. bases (KBs) of various kinds, to teach you some of the features of Istar, 
  7. and also to prod your thinking in how you could use it.  But there's lots 
  8. of facilities that you will not meet in this chapter.
  9.  
  10.       Before you start here, read the sections "How do I start it?" and
  11. "Going further" in the <Driving Istar> document.  This guide is at a higher 
  12. level: it does not describe the features of Istar so much as when you might 
  13. make use of them, for what purposes.
  14.  
  15.       We present several sections here, each a small project with Istar of
  16. about quarter of an hour.  Each is designed to let you see what Istar could 
  17. be useful for and at the same time how to employ its facilities.  It 
  18. provides an introduction not just to use of Istar facilities but to the 
  19. creation of KBs in general.  You will find some useful tips.  The first 
  20. eight or so sections take you through some of the potential benefits of 
  21. knowledge based systems and introduce the main features.  But the KB you 
  22. build during these is far from accurate.  Only towards the end do we 
  23. consider how to make the KB more accurate.
  24.  
  25.       At the end you should be able not only to drive Istar but to take
  26. your first steps in building real knowledge bases.  Have fun.
  27.  
  28.  
  29. 1.  EVALUATING STOCKS AND SHARES
  30.  
  31. Suppose your friend asked you for advice on buying stocks and shares.  As 
  32. an alternative to talking or writing to him you could give him a knowledge 
  33. base.  Then he could run it, it would ask him questions about a company he 
  34. is interested in and would offer advice.
  35.  
  36.       In this section you will create a (much simplified) knowledge base
  37. (KB) that gives such advice.
  38.  
  39.       What other reasons are there for building such a KB?
  40.  
  41.       (a)  For yourself: it would remind you at a later date of the advice
  42.       you were giving; so a KB can be your memory.
  43.  
  44.       (b)  This could be useful for legal reasons; so a KB can be a precise
  45.       record of knowledge.
  46.  
  47.       (c)  You could provide it to 100 friends and acquintances, almost as
  48.       easily as to the initial friend; a KB can be a distribution
  49.       mechanism.
  50.  
  51.       (d)  You could sell it.
  52.  
  53. So, let's start building it.
  54.  
  55. #  Fuzzy knowledge.  Buying shares depends on 'fuzzy' factors like the 
  56. quality of the management, the strength of the market, etc. as well as on 
  57. quantitative ones like share price.  So we will use Bayesians to build our 
  58. KB - these allow accumulation of fuzzy evidence for and against various 
  59. propositions.  In the top-right window (Item Types) select 'Bayesian'.
  60.  
  61. #  Drawing an inference net.  Draw a box (Driving step 3) towards the right 
  62. of the screen and name it 'Buy It' (Driving step 8).  (Note the wee 'OK' 
  63. button to the right of the Label gadget; it is a version of the main one 
  64. further below, there for your convenience when all you are doing is to fill 
  65. in a name or meaning.)  This is the 'goal' item, the thing we want to find 
  66. out, the overall purpose of our KB.
  67.  
  68. #  Draw two more boxes a couple in inches to the left of 'Buy It', calling 
  69. them 'Will grow' and 'More profits', which express the ideas that the 
  70. company will grow in the future and that its profits are likely to 
  71. increase.
  72.  
  73. #  (Naming.  You can use longer names if you wish, but the shorter the 
  74. better.  A good rule for naming of this kind of fuzzy qualitative concept: 
  75. make the name a short proposition rather than a numeric value.  So just 
  76. 'Profits' can be confusing since it could mean "Profits are likely to 
  77. increase" or "The numerical value of last year's profits".)
  78.  
  79. #  Both are good indicators that shares in the company are worth buying, so 
  80. we link them to 'Buy it'.  Draw a link from 'Will grow' to 'Buy it' and 
  81. from 'More profits' to 'Buy it'.  (Your KB should now resemble a V on its 
  82. side if the two antecedents, 'Will grow' and 'More profits', are to the 
  83. left of 'Buy it' and slightly higher and lower than it.)
  84.  
  85. #  Run it (Driving step 11) with a company in mind - fictitious or real. 
  86. It will ask you to provide slider values that represent your degree of 
  87. belief, first your belief that the company will grow, then your belief that 
  88. the company's profits will increase.  Belief is positive to the right, 
  89. negative to the left, the further from the centre, the stronger your 
  90. belief.  (Note: at this stage, it just puts the name before you.)
  91.  
  92. #  Look at the result (Driving step 12).  Not very interesting yet and 
  93. probably totally wrong in its result, but you have built your initial KB. 
  94. Not really ready for your friend, so let's add some more knowledge.
  95.  
  96. #  What determines whether a company - any company - will grow?  There are 
  97. many factors, and we'll add a few below.  But for now we'll only add two: 
  98. the company is in a growth sector of the economy and the company has good 
  99. management.  So add two antecedents to 'Will grow' (draw two boxes with 
  100. names e.g. 'Strong sector' and 'Good management', and link them to 'Will 
  101. grow').  Now a create a couple of antecedents for 'More profits' and link 
  102. them in: the company has a good financial history ('Good fin hist') and the 
  103. company has low overheads ('Low overheads').  Now the KB looks like a 
  104. branching tree on its side.
  105.  
  106. #  But most KBs are not pure trees but networks.  Connect 'Good management' 
  107. to 'More profits', showing that we believe that increases in profits are 
  108. more likely with good management.
  109.  
  110. #  Run the KB; it will now seek your degree of belief about four things: 
  111. Strong sector, Good management, Good fin hist and Low overheads.  Make some 
  112. positive, some negative.
  113.  
  114. #  Save it, by clicking the 'Save As' button on the main control panel (top 
  115. left).
  116.  
  117. #  To summarize, in this section we have:
  118.  
  119.       #  Noted several reasons for building a KB.
  120.       #  Used bayesian attributes/items to represent fuzzy knowledge ..
  121.       #  .. in terms of degrees of belief.
  122.       #  Drawn an inference net to evaluate attractiveness.
  123.       #  Run it.
  124.  
  125.  
  126.  
  127. 2.  DECISION SUPPORT - WHAT-IFFING
  128.  
  129. A KB like the one you have just created can be used in a decision support 
  130. mode.  If we run it several times giving different answers each time then 
  131. we can see the effect of the various factors.  This is called what-iffing. 
  132. From this we might find that certain factors are more important than others 
  133. and this can help us plan e.g. where to put resources.
  134.  
  135. #  Run the KB (Driving step 11 and 12) with Strong Sector and Good fin hist 
  136. having strong positive belief (100) and Good Management and Low overheads 
  137. having strong negative belief (-100).  The result should be slightly to the 
  138. left of centre, around 33%.  (Notice that your input is in terms of degrees 
  139. of belief while the answer is in terms of probability, but visually they 
  140. should be similar at present: left of centre is negative indication, right 
  141. is positive.)
  142.  
  143. #  Now run it again (shortcut from the data panel to the action panel by 
  144. pressing the OK-Act button rather than the OK button).  Reverse the answers 
  145. and you should obtain a slightly positive indication, 66%.
  146.  
  147. #  We can derive some initial knowledge from this: the combination of Good 
  148. management and Low overheads is a stronger indication of whether to buy 
  149. than the combination of Strong sector and Good financial history.  (That 
  150. assumes our knowledge base is correct and complete, of course, which is 
  151. certainly is not!)  This is the way we use KBs for decision support: try 
  152. various combinations of factors against others.
  153.  
  154. #  But is there any overriding factor?  Run again, giving the first two 100 
  155. and the second two -100.  The result should again be slightly positive. 
  156. Then try other combinations of pairs of 100 and -100.
  157.  
  158. #  What should happen is that the pair that contains Good management should 
  159. always determine the final result.  What this means is that good management 
  160. is a more important indicator than the others.  In looking at the KB it 
  161. should be obvious why this is so:  Good management feeds its influence 
  162. through to the final goal ('Buy it') by two routes while the others feed 
  163. their influence by only one.  All other things being equal, the more routes 
  164. by which a factor feeds through to the goal the more important it becomes.
  165.  
  166. #  But in most real KBs all other things are not equal; the links 
  167. themselves have varying strengths (weights).  So you cannot determine the 
  168. strong factors merely by looking at the net; you must run it to find out.
  169.  
  170. #  (Above we always divided the factors into pairs and always gave them 
  171. extreme values; that was just to give you the idea; in reality all sorts of 
  172. values would be used and we might vary only one or two factors at a time.)
  173.  
  174. #  To summarize, in this section we have:
  175.  
  176.       #  Used the KB in what-if mode.
  177.       #  Thereby found which factors are important.
  178.       #  Noted the effect of parallel inference paths.
  179.  
  180.  
  181.  
  182. 3.  MAKING IT EASIER AND TIDIER TO USE
  183.  
  184. When your KB becomes larger the above procedure becomes a bit cumbersome. 
  185. Here are a couple of things to tidy it up and make it less cumbersome.
  186.  
  187. #  First, let us put in proper question text for the degrees of belief. 
  188. What we do is to provide question text for each of the four antecedent 
  189. factors.  To do this, for each in turn do the following:  Click with the 
  190. RIGHT mouse button on the middle of the box expressing the item.  (The 
  191. attribute panel should appear; if nothing happens, it is probably that the 
  192. main easel is not active; to make it active, click on the easel with the 
  193. left mouse button as per normal Intuition practice.)  In the attribute 
  194. panel, find the first long string gadget, the 'Q' to the right of 'User 
  195. supplied'.  This is the question text.  Click in it and fill in the 
  196. question texts, e.g. "Do you believe the company is in a strong sector?", 
  197. "What is your degree of belief that the company has good management?", 
  198. "Have they a strong financial history?", "Do you believe they have low 
  199. overheads?"  Now, run the KB again, and your questions should appear.
  200.  
  201. #  Second, it's a nuisance having to bring up the attribute data panel each 
  202. time to see the result.  We can show the result directly on the main easel. 
  203. To do this bring up the attribute data panel for 'Buy it' (Driving step 8 
  204. or 12).  At the left end of the third row of gadgets is a check box 'Show 
  205. Value'.  Click that so that a tick appears.  Click Ok-Act to bring up the 
  206. action panel and run the KB again.  You should see a short black value line 
  207. part way across the bottom of the 'Buy it' box.  This shows its current 
  208. value as a probability; the longer it is, the higher the probability or 
  209. degree of belief in the concept expressed by the box.  Run it a few times 
  210. and you can see how the value changes, not so precisely as with the data 
  211. panel but enough to give a useful indication.  (Note: the show value 
  212. facility does not work for all data types at present; only booleans, 
  213. probabilities, proportions and bayesians.)
  214.  
  215. #  Such a value line is solid when the attribute is answered, and dotted 
  216. when it is unanswered.  By judicious choice of which attributes have value 
  217. lines you can gain a visual indication of how the KB is progressing.
  218.  
  219. #  Third, you can do this with all the antecedents too, showing their 
  220. values.
  221.  
  222. #  Fourth, if you just want to change a single input antecedent, you don't 
  223. have to reset and re-ask all the others.  Suppose you want to see the 
  224. effect of varying just 'Good management'.  Click on it with the left mouse 
  225. button to bring up an action panel for it.  Then hit Reset and Infer.  You 
  226. will be asked only for Good management.  But the answer will be propagated 
  227. through to 'Buy it'.  Try this several times.  Forward propagation does not 
  228. stop at the current goal (i.e. for which an action panel has been raised), 
  229. but spreads throughout the entire KB net as far as possible.  By varying 
  230. 'Good management' between its extremes you can see the maximum potential 
  231. effect it can have, which is a good indication of its importance.  (Note: 
  232. For this to work properly, you should ensure that the final goal, 'Buy it', 
  233. has been answered.  If it is not answered then the effect of 'Good 
  234. management' will not be propagated through to it because propagation 
  235. usually only occurs once an attribute is answered.)
  236.  
  237. #  (There is also an override facility, by which you can do similar what-
  238. iffing with items in the middle of a net; but we will not cover that here.)
  239.  
  240. #  A goal is an attribute whose value we are interested in obtaining, by 
  241. the backward and forward chaining process and the question sequence.  So 
  242. far, to obtain the value of a goal like 'Buy it' you have had to bring up 
  243. the attribute action panel, then hit Reset and Infer.  But suppose we have 
  244. twenty such goals; it would be tedious to do this twenty times.  As we will 
  245. see below, we can set up goal lists to make this cumbersome.
  246.  
  247. #  Not yet saleable.  Your KB is probably tidy enough to be usable by you 
  248. and by your friend if s/he is sympathetic.  But it is not yet tidy enough 
  249. to sell (even supposing that the knowledge is complete and accurate).  That 
  250. involves setting up goal lists etc. which we will not discuss here.  But 
  251. this version of Istar is not designed to take you all the way to building a 
  252. commercially attractive KB.
  253.  
  254. #  To summarize, in this section we have:
  255.  
  256.       #  Attended to ease of use and tidiness.
  257.       #  Introduced question text.
  258.       #  Used the Show Value facility.
  259.       #  Inferred single attributes on their own.
  260.       #  Used goal lists.
  261.  
  262. In some versions a simple shares advisor can be found in the KBs/Shares 
  263. file.  It is far from complete, and must not be used to give advice.  But 
  264. loading and running it could be instructive.
  265.  
  266.  
  267. 4.  KNOWLEDGE REFINEMENT AND CLARIFICATION
  268.  
  269. By now you have probably thought about other factors that should be taken 
  270. into account when deciding whether to purchase shares.  Also, you have 
  271. probably thought that concepts like 'Good management' are a bit vague.
  272.  
  273.       You'd be right on both accounts.  What has happened is that in the
  274. act of putting the KB together and then trying it a few times your thinking 
  275. about the domain of knowledge has been stimulated.  This can be just 
  276. remembering things; it can also be actual refinement or clarification of 
  277. your own knowledge.  Istar can help you to clarify and refine your 
  278. knowledge, which is especially useful is decision support.
  279.  
  280. #  The first step in refinement or clarification of knowledge is to set 
  281. down precise meanings.  By 'Buy it' we mean something like "This company's 
  282. shares are worth buying at the moment."  So bring up the attribute details 
  283. panel for 'Buy it'.  Top right is a string gadget for 'Meaning'; into it 
  284. put text similar to that.
  285.  
  286. #  Important Tip:  Normally you should fill in the meaning as soon as you 
  287. create the box.  (We have done so later here because of the order in which 
  288. these tutorial sessions have been planned.)
  289.  
  290. #  (Tip:  Notice several things that have been specified when making the 
  291. meaning of 'Buy it' precise:
  292.  
  293.       #  What we buy: "shares"
  294.       #  Which we buy:  "of this company"
  295.       #  The situation (when, where, etc.): "at the moment".
  296.  
  297. Making meaning precise often involves asking what, when, where, who, which, 
  298. etc.)
  299.  
  300. #  Now make the meaning of 'Strong sector' precise.  What about: "The 
  301. company operates is a strong and growing sector."  Notice the inclusion of 
  302. growth as well as general strength.
  303.  
  304. #  This inclusion of growth sets us thinking: we are happy about steady, 
  305. well-founded growth, but maybe not about artificially induced boom-type 
  306. growth.  So, for now, go back to 'Strong sector' and alter its Meaning to 
  307. "... strong and growing (but steady, not boom) sector."  (Note how we are 
  308. frequently accessing the Meaning gadget, and how useful is the wee 'OK' 
  309. button.)
  310.  
  311. #  Now make the meaning of 'Low overheads' precise; devise your own text.
  312.  
  313. #  Now try 'Good management'.  This one's perhaps not so easy to define. 
  314. The two links we have from it, to 'Will grow' and 'More profits', speak of 
  315. two aspects of quality of management.  The link to 'Will grow' speaks about 
  316. the extent to which the management has a vision to grow the company and has 
  317. the skills to do so, such as marketing.  The link to 'More profits' speaks 
  318. more about the financial policies of the management: is their spending 
  319. under control, is their investment policy sound, and so on.  So, as we try 
  320. to make the meaning precise we see that perhaps there are several things 
  321. currently bound together in the single concept 'Good management'.
  322.  
  323. #  We have several options here.  We can retain the the single, composite 
  324. concept.  We can split the concept into several others.  Or we can do both. 
  325. We will do both, first splitting it and then reinstating it for usability 
  326. purposes.
  327.  
  328. #  Pull the 'Good management' box over to the left of the others, leaving 
  329. enough space to place a couple of boxes between it and the others.  The 
  330. links extend to follow it.
  331.  
  332. #  Draw a box and label it 'Vision for growth' and give it a meaning like 
  333. "The management of this company has a vision for growth."  Place it 
  334. somewhere north-east of 'Good management'.
  335.  
  336. #  Now we will redirect a link.  Hold the left shift key down.  This 
  337. enables you to 'pick up' the end of a link and move it to another box. 
  338. Place mouse cursor over the end of the link from 'Will grow' where it 
  339. leaves the 'Good management' box and press left mouse button and drag the 
  340. mouse.  The link should now leave the box and follow the mouse.  Release 
  341. the end of the link over the new 'Vision for growth' box.  (Oops:  The 
  342. wrong link (the one to More Profits) is picked up instead?  It picks up the 
  343. link nearest to the mouse cursor position.  Hit Escape and try again. 
  344. Oops:  It doesn't pick up the link but rather starts drawing a new link or 
  345. box?  You didn't keep the Left Shift key down while you pressed the LMB. 
  346. Oops:  The box grows or shrinks in size as you moved the mouse?  That 
  347. happens if you hold the Right Shift key down istead.  In either case, hit 
  348. Escape and try again.)
  349.  
  350. #  If you run the KB now you will be asked about 'Vision for growth' as 
  351. well as all the others.
  352.  
  353. #  (Note:  The ability to redirect a link so easily is a boon: in many 
  354. pieces of software you have to delete the link and draw a new one.  While 
  355. this is not much of a problem here, once you have added weights to the link 
  356. and perhaps routed it around the diagram you lose all that information and 
  357. have to reinstate it all again.)
  358.  
  359. #  Now draw a box 'Good fin policy', somewhere south east of 'Good 
  360. management', with meaning like "The management of this company has sound 
  361. financial policy."  Redirect the link between 'Good management' and 'More 
  362. profits' in the same way as above so that it now starts at 'Good fin 
  363. policy'.
  364.  
  365. #  (Notice:  We still have a 'Good management' box but it is not connected 
  366. to the goal 'Buy it'.  If you run the KB now it will no longer ask about 
  367. 'Good management'; backward chaining only reaches those parts that are 
  368. connected to the goal.  We could delete it, but as there is no need to do 
  369. so and as we sometimes find we need such items later, just leave it and 
  370. ignore it.  We will come back to it at the very end, making the KB more 
  371. usable.)
  372.  
  373. #  Now that we have identified sound financial policy as a relevant concept 
  374. in our KB we notice its similarity with good financial history.  Assuming 
  375. that the management has been in place for some time, presumably the good 
  376. financial history is due in part to sound financial policy.  So we really 
  377. want 'Good fin policy' to link into 'Good fin hist' as well as directly 
  378. into 'More profits'.  Link them (drawing a line from the right hand edge of 
  379. 'Good fin policy' into 'Good fin hist' - if 'Good fin policy' is above 
  380. 'Good fin hist' then you might want to make the link S-shaped, using the 
  381. space bar to insert bends).
  382.  
  383. #  To come to think of it, maybe we shouldn't have 'Good fin hist' at all. 
  384. Maybe it is almost completely subsumed under 'Good fin policy' as far as 
  385. 'More profits' is concerned?  So we will merely delete the link from 'Good 
  386. fin hist' and 'More profits' so that the former no longer has influence on 
  387. the latter.
  388.  
  389. #  (We have the option of at least two other courses of action: delete the 
  390. item 'Good fin hist' or merge it with 'Good fin policy'.  See the section 
  391. on Common Net Manipulations.  Deletion of an item is more drastic than 
  392. deletion of a link and in knowledge refinement it is often to err on the 
  393. side of caution.  Even though the two concepts appear similar as far as 
  394. 'More profits' is concerned, they are not in fact identical in terms of 
  395. their actual meaning, and it might come about that later parts of the KB 
  396. require 'Good fin hist' as distinct from 'Good fin policy'.)
  397.  
  398. #  Deleting a link.  With right mouse button click over the link between 
  399. 'Good fin hist' and 'More profits'.  Up comes a Relationship Instance panel 
  400. with details of this particular link.  (Notice, in passing, the Unary Op 
  401. type ('Normal') and the Weight figures towards the bottom which is 
  402. contained in four small boxes and should read 3,1, 1,3.)  But ignore all 
  403. else but the 'Delete' button.  Click it.  The link disappears.
  404.  
  405. #  Save (Save-As) the KB as 'R1' so we can pick it up later.
  406.  
  407. #  While we have been manipulating the concepts above, maybe you have 
  408. thought of other factors that contribute to a belief that this company's 
  409. shares are worth buying?  If so, you can always add it: just place a box 
  410. for it, link it to 'Buy it' and give it a name and meaning.  Maybe you've 
  411. thought of something extra that contributes to a belief in 'Will grow' or 
  412. any other box.  Add the new concept(s) in the same way.
  413.  
  414. #  Negative evidence.  Lastly, for now, maybe you have also thought of some 
  415. factor that would lower your belief in 'Buy it'.  For instance, even if we 
  416. believe the company will grow and its profits will increase, if there are 
  417. rumours that its management have been involved in shady dealings, then 
  418. perhaps it would be dangerous to buy shares.  So, in a suitable space to 
  419. the left of 'Buy it' draw a box 'Shady dealing' with meaning "The 
  420. management is believed to have been involved in shady deals."  Now start 
  421. drawing a link from 'Shady dealing' towards 'Buy it', but while you are 
  422. drawing it, hit the Minus key (to right of '0' on top row of keyboard). 
  423. You should see the line change colour from red to black, indicating that it 
  424. is now a negative link.  (If you change your mind, and want to change it 
  425. back, hit the Plus key.)  Then release the link over 'Buy it'.
  426.  
  427. #  Negative evidence acts in a similar way to normal evidence, except that 
  428. its effect is reversed.  When you run a KB with a negative link, as you 
  429. increase belief in the negative evidence then it decreases belief in its 
  430. consequent.  Try it in the what-iffing mode described above.
  431.  
  432. #  Click right mouse button over the negative link to obtain its 
  433. Relationship Instance panel.  Notice that the Unary Operator is 'Negate'. 
  434. For all the positive links in your KB the Unary Operator is 'Normal'.  If 
  435. you ever want to change a link from positive to negative or vice versa once 
  436. it is drawn, then bring up this panel and change its Unary Op type (click 
  437. the wee button to left of its name, as described for Inference type in 
  438. Driving step 13).  Then click 'OK'.
  439.  
  440. #  Notice how our process of knowledge refinement works, in several ways, 
  441. and of course there are others.  Istar provides an easy to use too to aid 
  442. the process of knowledge refinement and clarification.
  443.  
  444. #  To summarize, in this section we have:
  445.  
  446.       #  Found several ways of refining knowledge:
  447.       #  .. by making meanings precise
  448.       #  .. by splitting a concept to become more than one
  449.       #  .. by merging two concepts that are (almost) the same
  450.       #  .. by thinking of other concepts
  451.       #  Noted how these happen naturally as we build the KB.
  452.       #  Used the facility to redirect links.
  453.       #  Deleted a link.
  454.       #  Used negative evidence.
  455.  
  456.  
  457.  
  458. 5.  KNOWLEDGE COMMUNICATION AND MUTUAL UNDERSTANDING
  459.  
  460. Imagine carrying out knowledge refinement with a colleague, both of you 
  461. around the screen.  To have someone to bounce ideas off is often very 
  462. fruitful.  And it is often of benefit to ensure the newly emerging ideas 
  463. are communicated to a colleague - and understood by a colleague.  Istar is 
  464. designed for partnership working, where two (or a few) people are around 
  465. the screen.
  466.  
  467.       (Note: This is NOT the same as group working where each has their own
  468. screen linked by some electronic means, though in principle Istar could 
  469. support that.  What we are talking about here is the technically more 
  470. modest situation - but probably socially and practically more useful 
  471. situation - where two or more people sit around a single screen.)
  472.  
  473.       You have a partially developed KB up in front of you and your
  474. colleague.  Think of the knowledge refinement steps we have been through:
  475.  
  476.       #  making meanings precise
  477.       #  a concept becomes more than one
  478.       #  two concepts are seen to be (almost) the same
  479.       #  thinking of other concepts.
  480.  
  481. If a colleague sat with you, there are four things that could be going on. 
  482. The first two occur when knowledge is being refined, as above.
  483.  
  484.       #  First, your colleague just observes your actions and listens to
  485.       you as you refine your knowledge.  Then your thinking and reasoning
  486.       would be communicated.  S/he would understand why you believe, for
  487.       instance, why 'Good management' is not a sufficiently precise
  488.       concept.  Using Istar helps this communication and mutual
  489.       understanding of what are often ill-defined areas.
  490.  
  491.       #  Second, your colleague takes an active part in the refinement
  492.       process, as the two of you discuss whether 'Good management' should
  493.       be split in two, in three, or kept as a whole.  Using Istar
  494.       facilitates this discussion by providing a graphical 'language' in
  495.       which to express and try out ideas.
  496.  
  497. The third and fourth occur when knowledge is already in a reasonably clear 
  498. state and is merely being set down into the KB without being refined. 
  499. (This might happen, for instance, when you are entering knowledge from a 
  500. rulebook or knowledge of established good practice.)
  501.  
  502.       #  Third, your colleague just observes you building the KB.  But the
  503.       order in which you build it communicates something of importance.  So
  504.       does your 'body language' while building it - for instance, the act
  505.       of moving 'Good management' to the left to make room gives
  506.       information about your intentions.  Istar is then facilitating simple
  507.       one-way, communication, but of more than pure information.
  508.  
  509.       #  Fourth your colleague takes an active part in the construction
  510.       process: "Haven't you forgotten X factor?", "Is that how you
  511.       interpret that rule; I would interpret it in a different way."
  512.       Again, Istar facilitates communication, but this time a two-way
  513.       communication.
  514.  
  515.       In addition to its clear graphical display and intuitive mechanisms
  516. for drawing knowledge bases, it has been found that a third facility is 
  517. very important for communication:  the flashing up of the meaning of an 
  518. item at the bottom of the screen as the mouse runs over it.  You've almost 
  519. certainly noticed it, but if not, just move the mouse over the items of 
  520. your KB.  (If nothing happens, it is probably because the main easel window 
  521. is not active, and so you must make it so by clicking over its background.)
  522.  
  523.       Superficially like the speech bubbles that come up in MUI, Windows or
  524. the Mac, that explain what a button is for, this has a rather more 
  525. sophisticated use in showing high level meaning rather than low level 
  526. action.  It was found during the INCA project (Basden, Brown, Tetlow and 
  527. Hibberd, 1996) that the knowledge engineer (yourself) made little use of it 
  528. since it was not in the main field of view but the onlooker (your 
  529. colleague) made enormous use of it to see the meanings of the various items 
  530. of itnerest.
  531.  
  532.       To summarize, in this section we have:
  533.  
  534.       #  Noted how Istar can aid communication in four ways
  535.       #  .. by working with a colleague
  536.       #  .. who either actively takes part or just observes.
  537.       #  Noted the use of Istar's facility to show meaning.
  538.  
  539.  
  540.  
  541. 6.  TYPES OF BENEFIT OF A KB
  542.  
  543. We have now discussed four types of benefit that can accrue from a KB.  In 
  544. the first two:
  545.  
  546.       #  simple evaluation of the attractiveness of a share
  547.       #  what-iffing to find significant factors
  548.  
  549. the benefit accrues from running a completed KB, while in the latter two,
  550.  
  551.       #  refinement and clarification of your knowledge and
  552.       #  communication and discussion,
  553.  
  554. the benefit accrues from the process of constructing the KB, rather than 
  555. running it.  For the remaining sections we will return to types of benefit 
  556. that can accrue from running a completed KB, and how these benefits 
  557. influence the form and style of the KB:
  558.  
  559.       #  predicting behaviour
  560.       #  selection from known options
  561.       #  selection from undefined options
  562.       #  causal modelling
  563.       #  diagnosis
  564.       #  critiquing.
  565.  
  566. All these assume a completed KB and the benefits accrue from running it. 
  567. The KB you have already built is general purpose and can fulfil most of the 
  568. purposes but with varying degrees of clumsiness.  For most effective use 
  569. the KB should be tailored to the purpose for which it is designed.
  570.  
  571.       I say purposes rather than purpose because many KBs hold knowledge
  572. for more than one purpose.  For instance the Wheat Counsellor KB first 
  573. predicted what diseases were likely in a crop of winter wheat and then 
  574. selected the appropriate preventative treatment.  But we will look at the 
  575. style required for each purpose, and as we do, will meet and learn about 
  576. various facilities of Istar.
  577.  
  578.  
  579. 7.  PREDICTING THE BEHAVIOUR OF YOUR SHARE
  580.  
  581. Your knowledge has been refined and the KB now expresses what you believe 
  582. about share purchasing (or let us suppose so).  As you might have realised, 
  583. your KB can be used to predict outcomes.  Suppose you have knowledge of a 
  584. particular company and its situation.  Then if you poke this information 
  585. into the KB it will predict the attractiveness of the shares of that 
  586. company to investors.
  587.  
  588. #  All you have to do is to run the KB; there is no change required to the 
  589. knowledge.  (Bring up the action panel for 'Buy it' and click Reset and 
  590. Infer.)
  591.  
  592. #  What this underlines is that a well designed KB is actually multi-
  593. purpose when run:  for evaluation, critique, understanding, communication 
  594. and prediction.  Just as with any good model.  So, in a sense, a good KB is 
  595. a model of reality and Istar can be seen as modelling software.  But, as 
  596. those of you who have been involved in modelling will have realised, a 
  597. rather different style of software.
  598.  
  599. #  So far you have been dealing with bayesians, representing fuzzy 
  600. concepts.  But much modelling deals with harder or more precise concepts, 
  601. and for these we need numbers, booleans, etc.  Istar provides a host of 
  602. these (though the current version as of June 1996) is still under 
  603. development.  For the full list, see the file Value Types.  For now we will 
  604. use numbers and booleans.
  605.  
  606. #  A boolean is like a sharp, hard bayesian, the common true-false, yes-no 
  607. distinction.  Bring up the attribute details panel for 'Strong sector'.  On 
  608. the second row of gadgets, headed 'Value', the leftmost shows the value 
  609. type (Bayesian).  Click on the wee type-change gadget at its left-hand end 
  610. and a list of value types appears.  Select Boolean (and hit its OK button). 
  611. (If you get a warning message that value type is inconsistent with 
  612. inference method, it just means that 'Strong sector' is set to 'Infer' 
  613. rather than 'User supplied'; ignore it for now as it will have no effect 
  614. since there are no antecedents.)  You will see the value type in the 
  615. attribute detail panel change - but it has not come into effect yet.  So 
  616. click 'OK'.  Then bring up the attribute detail panel again, and you will 
  617. see that the value gadget itself, to the right of the value type 
  618. identifier, is no longer a slider but a checkbox.  You have changed value 
  619. type.
  620.  
  621. #  Now run it, and you will see that when it asks about 'Strong sector' it 
  622. no longer gives you a slider but a check box.  (Rather ugly, this tiny 
  623. checkbox; in future versions there will be an option of a larger gadget 
  624. saying Yes/No.)
  625.  
  626. #  Now for a numeric value.  We'll use floating point numbers here, though 
  627. there are other types including integers, ratios, ordinals, enumerators, 
  628. proportions, etc.  First, we'll practice with just numeric values, then 
  629. we'll use a numeric value in our bayesian network, which takes a bit more 
  630. thought.  Because: how can we integrate a numeric concept like Share Price 
  631. into a fuzzy propositional concept like whether or not to buy the share? 
  632. Think about it as we practice some numerics.
  633.  
  634. #  Distance is half of acceleration times the square of time (if I remember 
  635. my school physics correctly).  On the Select Item Type panel click on 
  636. Float.
  637.  
  638.       1.  In a clear part of the easel (notice how it smoothly scrolls as
  639.       you move the mouse - a wonderful feature of the Amiga!) lay down an
  640.       item and label it 'Distance'.  This will be our goal.
  641.  
  642.       2.  Then lay down three antecedents to the left of it: 'Time',
  643.       'Acceleration' and 'Constant'.
  644.  
  645.       3.  Link all of them to 'Distance'.
  646.  
  647.       4.  Bring up the attribute details panel for 'Distance' and locate
  648.       the Inference Method type gadget.  It should lie just to the right of
  649.       the 'Infer' radio button and should say "X = A + B + C .." or
  650.       something similar, meaning that the value of this attribute is
  651.       calculated by adding together the values of all the antecedents.  We
  652.       want multiplication, so click on the wee type-change button at its
  653.       left hand end and select "X = A * B * C .." from its list.  Click OK.
  654.  
  655.       5.  But we want the square of time, not time itself: draw a second
  656.       link from 'Time' to 'Distance', putting a bend in it (Driving step 5)
  657.       to visually distinguish it from the first one; having two links gives
  658.       the square of distance, having three will give the cube, etc.
  659.  
  660.       6.  Bring up the attribute details panel for 'Constant', set the
  661.       derivation radio button to 'Const' and set the value to '0.5', click
  662.       its OK button.
  663.  
  664. #  What you have is a wee inference net that says the result is the product 
  665. of Time, Time, Acceleration and the constant, 0.5.  Bring up the action 
  666. panel.  Run it, giving a time of 2 and an acceleration of 3, say.  The 
  667. result should appear as 6.  With this you can predict how far a stone will 
  668. fall from the top of a tower block in a given time.  (Or, as mentioned in 
  669. the first paragraph, you can put this to other uses such as evaluating 
  670. whether the stone will reach the 23rd floor in three seconds, such as doing 
  671. a what-if on different strengths of gravity, such as refining your 
  672. knowledge of what factors contribute to distance fallen.)
  673.  
  674. #  Now, how can we link a numeric concept into a bayesian network?  The 
  675. answer is that we cannot meaningfully link it in directly.  Instead, we 
  676. must often compare the numeric attribute with something and emerge with a 
  677. truth statement.  So, for instance, we could say that if the Share Price is 
  678. going up (greater than it was a week ago) then we predict that the share is 
  679. worth buying.  So let's put that in.  (I know that knowledge is wrong; you 
  680. can refine it below!)  It takes several stages, since you will learn and 
  681. use several new features.
  682.  
  683. #  First, place two Float boxes south west of 'Buy it' with enough space 
  684. for another between them.  Label them 'Share Price' and 'Price last week', 
  685. giving meanings of "Current share price of this company" and "The share 
  686. price of the company a week ago".  If you like, give them suitable question 
  687. text.
  688.  
  689. #  Now select Boolean item type, draw an item between 'Buy it' and these 
  690. two.  Label it 'Shares Rising' with a meaning "The share price is rising".
  691.  
  692. #  Now link 'Share Price' as antecedent to 'Shares Rising'.  Then link 
  693. 'Price last week' similarly.  Do it in that order.
  694.  
  695. #  Bring up the attribute details panel for 'Shares Rising'.  Change the 
  696. inference method to "Whether A > all".  What this inference method does is 
  697. to see whether the first antecedent is greater than all the rest (that is 
  698. why the order was important).  It returns a boolean result (unlike most 
  699. inference methods, in which the consequent is of the same value type as the 
  700. antecedents).  Click OK.
  701.  
  702. #  (If you wish to see this in operation, run the wee KB in which 'Shares 
  703. Rising' is the goal, giving various pairs of values for 'Share Price' and 
  704. 'Price last week'.)
  705.  
  706. #  Now link 'Shares Rising' as antecedent into 'Buy it'.  Strictly, the 
  707. bayesian accumulation inference method (which 'Buy it' has) needs bayesian 
  708. actecedents.  But for your convenience Istar is tolerant, making automatic 
  709. conversions from probability and boolean.  (If the antecedent is a simple 
  710. probability it has no a-priori and this is assumed to be half (0.5, 50%). 
  711. If the antecedent is boolean, as here, then it is treated as a probability 
  712. with a value of either 0 or 100% with an a-priori of 50%.  For details of 
  713. a-priori values, see below.)  You will find automatic value type conversion 
  714. quite frequently, for instance allowing you to mix integers and floats when 
  715. doing arithmetic.
  716.  
  717. #  Now run the whole KB, and see the effect of changing share price 
  718. compared with price last week.
  719.  
  720. #  Knowledge refinement:  You probably disagree with the idea that shares 
  721. should be bought when their price is rising.  Many will say they should be 
  722. bought when price is falling and sold when rising.  That simple rule was at 
  723. the centre the stock market crash of 1989, so I thought we'd put in its 
  724. opposite here!  You are free to correct my possibly wrong knowledge to the 
  725. conventional rule, and there are several ways of doing it:  (a) alter 
  726. inference method from "Whether A > the rest" to "Whether A < the rest" (and 
  727. alter the label and meaning of 'Shares rising' in line with that).  (b) 
  728. (easier:) make 'Shares rising' negative evidence for 'Buy it', by altering 
  729. the unary operator of its link to 'Negate'.  Probably, the real knowledge 
  730. of the link between share price movement and whether to buy is more 
  731. complex, depending on the rate of price rise or drop, how long it has been 
  732. rising or dropping, and what other dealers are doing.  It would be a good 
  733. exercise to try to work out a small knowledge base for this, now you have 
  734. the ability to connect numeric and bayesian information.
  735.  
  736.       In this section we have:
  737.  
  738.       #  noted the use of a KB for prediction as well as others
  739.       #  made use of numeric information
  740.       #  found one way of linking numeric and bayesian
  741.       #  noted there are two ways of negating knowledge.
  742.  
  743.  
  744. 8.  SELECTION: DECIDING WHICH SHARE TO PURCHASE
  745.  
  746. Istar can be used to select options, especially where the selection 
  747. criteria are fuzzy and make use of human 'judgement'.  This section looks 
  748. at one way of doing this.
  749.  
  750.       So far, our KB is run for a single company, and we have been
  751. evaluating whether its shares are, or predicting whether it shares will be, 
  752. worth buying, but we can also use it to select the best company from which 
  753. to buy shares.  To use our existing KB we must run it several times, once 
  754. for each company, and remember the result for each one.  That is, the 
  755. general purpose KB we have constructed can also be used for selection.
  756.  
  757.       But running it for each company can be inconvenient.  For a start, we
  758. need to remember the result for each.  To continue, there are situations 
  759. where there is common information and we find we are having to enter the 
  760. same information each time.  This section looks at one way of allowing 
  761. several selections in a single KB.
  762.  
  763.       This method would not normally be used for selecting between such
  764. varied things as company shares, but mainly for selection from a small and 
  765. static range of options.  For instance, to select the best of five alloys 
  766. from which to make machine parts, depending on their properties.  But we 
  767. will continue with our shares KB and assume we have two companies between 
  768. which we must make a decision: Acme plc and Bloggs Ltd.  Both are in the 
  769. Information Technology sector.
  770.  
  771.       What we must do is to create separate parts of the KB for each, one
  772. part for Acme, one for Bloggs, but using as much common knowledge as 
  773. possible.  (Current version of Istar does not have a knowledge duplication 
  774. facility, so we must do it manually.)
  775.  
  776. #  Load the KB you saved as 'R1'.
  777.  
  778. #  First, let's rename the attributes in the existing KB as relevant to 
  779. Acme.  Easiest way to do this in our present version (few attributes) is to 
  780. bring up the attribute details for each attribute in turn and put an "A:" 
  781. (for Acme) in front of both label and meaning.  Do so - except for 'Buy it' 
  782. which is better labelled 'Buy Acme' and for 'Strong sector' which is common 
  783. data and thus not specific to either.  You can ignore the dangling 'Good 
  784. fin hist'.
  785.  
  786. #  Now we build a similar KB for Bloggs, but without 'Strong  Sector'. 
  787. Preferably underneath the current one.  Create items for:  'Buy Bloggs', 
  788. 'B: Will grow', 'B: Vision for growth', 'B: More profits', 'B: Good fin 
  789. policy', (but not for 'Strong sector'), and link them in the same pattern 
  790. as for Acme.  (Don't bother duplicating 'Good fin hist'.)  For 'Buy Bloggs' 
  791. hit the Show Value button on the Attribute Details panel, so, like 'Buy 
  792. Acme', the value is shown as a line in the box.
  793.  
  794. #  Now link the common 'Strong sector' above Acme into 'B: Will grow'. 
  795. 'Strong sector' is common to both because both are in the same sector, I.T. 
  796. (Note the long almost-vertical link you have created: this is a visual cue 
  797. in the diagram that says 'this link is different': unlike most, it is 
  798. common to the two parts of the KB.)
  799.  
  800. #  Make 'Strong sector' the first antecedent of 'B: Will grow', as 
  801. described in the following paragraphs ...
  802.  
  803. #  (A note about order of antecedents.  Bring up the attribute panel for 
  804. 'A: Will grow' and look at the bottom left corner List of Antecedents. 
  805. This tells you which items/attributes are the direct antecedents to this 
  806. one.  Notice that 'Strong sector' is first.  Now bring up that for 'B: Will 
  807. grow' (no need to send 'A: Will grow' away; Istar allows several such 
  808. panels to be up at the same time).  'Strong sector' should appear as second 
  809. in the list.  This is because we linked 'Strong sector' to 'B: Will grow' 
  810. after we linked the rest, not before; any new link is added at the end. 
  811. What this means is that if you run just 'Buy Acme' you will be asked about 
  812. sector strength first, while if you run just 'Buy Bloggs' sector strength 
  813. is asked second.  Normally this doesn't matter much because the order 
  814. should not affect the results (except for some order-sensitive inference 
  815. methods like "Whether A > the rest").  The main concern is over usability; 
  816. the user - your friend of the first section, perhaps - might wonder why the 
  817. two parts behave differently and whether this has any significance.  The 
  818. attribute details panel allows you to change the order by selecting an 
  819. antecedent and making it first.  So select 'Strong sector' on the list (by 
  820. hitting it with the LMB to highlight it) and click the nearby 'To 1' 
  821. button.  It should jump to first in list.  And if you run 'Buy Bloggs' now 
  822. it should ask about sector strength first.)
  823.  
  824. #  (The other buttons by the antecedent list - See, R, X - give you 
  825. information.  'See' takes you to the named antecedent, bringing up its 
  826. attribute details panel.  'R' takes you to the Relationship Instance panel 
  827. for the relationship.  In both cases the original panel stays.  'X' brings 
  828. up a textual explanation of what goes on in the inference relationship - 
  829. but in the current version it is only 90% correct since it is still being 
  830. implemented.  Try them, sending each away when you have seen them.)
  831.  
  832. #  Run both parts of the KB (Acme and Bloggs) by bringing up the Action 
  833. panels for both 'Buy Acme' and 'Buy Bloggs' (you can have any number of 
  834. attribute panels up at one time).  Hit Reset and Infer for Acme, and answer 
  835. the questions that come up.  Hit Reset and Infer for Bloggs, and answer the 
  836. questions that come up.
  837.  
  838. #  Now look at the two value lines for 'Buy Acme' and 'Buy Bloggs'.  (Oops: 
  839. No value line?  Bring up the Attribute Details panel for each and ensure 
  840. the Show Value button is ticked.)  Notice how useful these value lines are 
  841. for comparing two or more similar attributes - the longer one is the share 
  842. to buy.  If you move the boxes so that they are aligned vertically above 
  843. each other, then comparison is fast and easy.  (But it only works for 
  844. bayesians, booleans, probabilities and proportions at present, not integers 
  845. nor floats.)
  846.  
  847. #  Goal lists.  But notice also how cumbersome was the process of bringing 
  848. up all the attribute action panels individually; also, you probably noticed 
  849. that you were asked twice about the common factor, 'Strong market'.  It 
  850. gets worse the larger the number of goals you have.  But we can make it 
  851. easier by using goal lists.  Bring up the KB panel and look down the second 
  852. column of buttons - hit the one labelled 'Goal List'.  A Goal List panel 
  853. appears down the bottom right of the control screen; it is empty at the 
  854. moment.  Now bring up the Action panel for 'Buy Acme' (if not already up) 
  855. and hit the button labelled 'Add Goal'.  As you can see, this adds 'Buy 
  856. Acme' to the goal list.  Now do the same for 'Buy Bloggs'.  (Notice how the 
  857. latest goal to be added is always placed at the start of the list.  You can 
  858. rearrange the order of the goal list by selecting one and hitting 'To 1', 
  859. which makes that one first.  Make Acme first if you wish.)
  860.  
  861. #  Running with a goal list.  To run with a goal list is easy.  Bring up 
  862. the KB panel and hit ResetGoals and then InfeGoals buttons.  This will 
  863. start a multi-goal inference cycle, asking all the questions relevant to 
  864. all the goals until all are answered.  It should ask about strong sector 
  865. only once, but all the other information separately.
  866.  
  867. #  (To remove a goal from the goal list, bring up the goal list, select the 
  868. goal and hit Remove.)
  869.  
  870. #  (To find a goal in a large KB, select it and hit Show button.  Then look 
  871. at the easel: everything has disappeared except the goal and the attributes 
  872. it is connected to.  To bring the easel back, make sure it is active and 
  873. hit the Numeric Enter key (bottom right on keyboard).)
  874.  
  875. #  Here is another method of showing the result when you are comparing two 
  876. or more goals like 'Buy Acme' and 'Buy Bloggs'.  It is more suited to 
  877. numeric goals which cannot be shown by the horizontal value line.  We add 
  878. some extra inference net which compares the two and provides the name of 
  879. the best goal.  In doing so you will learn a new value type and couple more 
  880. facilities of Istar.
  881.  
  882. #  On the Select Item Type panel, towards the bottom select 'Block'.  The 
  883. Free Block value type means that the attribute contains the DSAP (data 
  884. structure area pointer, the reference number) of a block of data in the KB. 
  885. Place such an attribute/item to the right of the two goals, 'Buy Acme' and 
  886. 'Buy Bloggs'.  (Label: 'Best share', meaning e.g.: "This holds holds the 
  887. DSAP of the block of the share which is most attractive".)  Link them to it 
  888. as its attributes.
  889.  
  890. #  Bring up the attribute detail panel, and the inference method should be, 
  891. by default, "Which Max".  (If not, then change it.)  "Which Max" looks to 
  892. find which of the antecedents has the highest value and returns an 
  893. identifier to show which.  In our case the result is a DSAP of a block, but 
  894. it can be an index number if the consequent is integer or ordinal; see the 
  895. <Inference> file for more details.
  896.  
  897. #  (If you run it using 'Best share' as the goal - ignore the goal list, 
  898. bring up its action panel and click Reset and Infer - then the result will 
  899. be a number like 23720.  Now if you bring up the attribute details panels 
  900. for 'Buy Acme' and 'Buy Bloggs' you will see over the right hand side, 
  901. about 2/3 of the way down, a gadget 'DSAP' and one of them should be the 
  902. number you have just seen.  Rather meaningless since it is an internal 
  903. identifier.)
  904.  
  905. #  Now to convert this Block value (DSAP) into something more meaningful: 
  906. the name of the best share.  In the Select Item Type panel, select 'Free 
  907. String'.  Place a string item to the right of 'Best share' and link 'Best 
  908. share' into it as antecedent.  (You can call the new item 'Best share' if 
  909. you like as Istar allows duplicate names, but it's probably better to 
  910. differentiate it as a string version either by a different label or in the 
  911. meaning.)
  912.  
  913. #  (Notice how the colours of the labels in the various items/attributes is 
  914. a clue to the value type held.)
  915.  
  916. #  Now run the KB with this string 'Best share (string)' as goal, and look 
  917. at its result.  It should contain as its value either of the strings, 'Buy 
  918. Acme' or 'Buy Bloggs'.  This string value can then be placed in a document 
  919. (though we will not do so here; in the current version of Istar this 
  920. facility is not available).
  921.  
  922. #  Which is the better method to show which share to buy?  It depends.  But 
  923. the former (value lines) has two advantages.  One is that it is more 
  924. immediately graphical: look for the longest line.  But, more importantly, 
  925. suppose both results were low (e.g. 3% and 9%).  Then the second method 
  926. would simply say 'Buy Bloggs', whereas in reality it would probably be 
  927. inappropriate to buy either of them.  The second method, using "Which Max" 
  928. inference, makes the decision for the user while the first method merely 
  929. provides decision support for the user.  This is often more useful since if 
  930. two or more options have approximately the same value (e.g. 85%, 87%, 82%) 
  931. then it might be appropriate to choose one that is not numerically the 
  932. highest, for extraneous reasons.
  933.  
  934. #  Let's review what we've done.  We have a KB by which the user can choose 
  935. between Acme and Bloggs shares, given information about both companies and 
  936. the strength of the market.  The KB is identical for each.  But in many 
  937. selector KBs there will be small variations between the knowledge.
  938.  
  939. #  Suppose Acme is a small company and Bloggs a large one, and the user 
  940. might have a preference for large or small companies.  Select Bayesian 
  941. again and create an item labelled 'Prefers small', meaning "I prefer small 
  942. company shares".  (Notice that this is information pertaining to the user, 
  943. not to the companies or their situation.  Perfectly valid.)  Then link it 
  944. to 'Buy Acme' with a positive link and to 'Buy Bloggs' with a negative 
  945. link.  From previous work both 'Buy Acme' and 'Buy Bloggs' will be answered 
  946. and their values shown as horizontal lines in their boxes.  (If not, make 
  947. sure they are.)  Then bring up the action panel for 'Prefers small' and 
  948. reset/infer it several times with various values.  Depending on the other 
  949. information, you should see the balance between the two shares change as 
  950. you change preference.
  951.  
  952. #  In a selector KB, which has knowledge on how to select between a small, 
  953. static number of known options (like the alloys above) you will find some 
  954. knowledge that is duplicated across the options, some that is common to all 
  955. (like 'Strong sector') and some that differentiates between the options 
  956. (like 'Prefers small').  This is a general pattern.
  957.  
  958. #  To summarize, in this section, we have (not in this order):
  959.  
  960.       #  Set up a selector KB
  961.       #  Noted that some knowledge must be duplicated, ..
  962.       #  .. but that some is common
  963.       #  .. and some differentiates
  964.       #  In this case, the latter is info about the user
  965.       #  Noted how backward chaining lends intelligence
  966.       #  Dealt with the order of antecedents
  967.       #  Used graphical comparison of results
  968.       #  Used textual methods
  969.       #  Used the Block value type with automatic conversion to name
  970.       #  Used a selector inference method, "Which Max"
  971.       #  Discussed methods of comparison and selection.
  972.  
  973.  
  974. 9.  SELECTION: DECIDING WHAT CRITERIA TO JUDGE THEM ON
  975.  
  976. The previous section looked at the construction of a KB to select between a 
  977. small number of known options, such as alloys.  In company shares we do not 
  978. have a small number of known options, but rather a large number of options 
  979. which are not known until we run the KB.  That is, between yesterday's run 
  980. and today's five new companies might have come into existence and another 
  981. twelve might have gone bust.  In such domains it is better to take a 
  982. different approach to selection.  I also found that this approach was 
  983. needed when selecting tree species suitable for planting on a particular 
  984. plot of land.
  985.  
  986.       The approach we take here is not to hold knowledge of each and every
  987. option in the KB, but rather to use the KB to decide what selection 
  988. criteria should be used.  Then these selection criteria can be applied to a 
  989. database containing thousands of options (companies, tree species, etc.) 
  990. and the best few examined more closely.
  991.  
  992.       "But why not just use the database direct and apply a SQL query?" you
  993. may ask.  The answer is that with each run a different set of selection 
  994. criteria must be used, so that if we just used SQL direct we would have to 
  995. write a complex SQL statement each and every run.  In effect, the KB holds 
  996. the knowledge on how to write the SQL statement needed for each run. 
  997. (Though we will not attempt that in this section, one could do so with the 
  998. current version of Istar, using string value types and the "Concat" 
  999. inference method).
  1000.  
  1001.       Also - and this is what we found in the tree selector KB - simple SQL
  1002. or database access is not enough.  It is better if the KB itself can 
  1003. perform inference on data values obtained from the KB.  SQL etc. do not 
  1004. normally have bayesian mechanisms built into them.
  1005.  
  1006.       This kind of KB is rather more sophisticated in structure (as well as
  1007. in detail) than the ones above.  In the ones above, three kinds of 
  1008. information came together into the eventual goals:
  1009.  
  1010.       a)  about the requirements of the user
  1011.       b)  about the general situation, common to all options
  1012.       c)  about each specific option.
  1013.  
  1014. In this kind of selector, they separate out to some extent.  First we use 
  1015. (a) and some of (b) to arrive at a set of selection criteria, then we apply 
  1016. these to (c) and some more of (b) to find the relative attractiveness of 
  1017. each of the options.  In this kind of selector, (c) is often held in the 
  1018. database, but inferences from it must be made in the KB (not just in SQL) 
  1019. as discussed above.
  1020.  
  1021.       We will build a small KB for the first phase of a tree species
  1022. selector.  It will first be a simple KB using facilities we have already 
  1023. met above.  Then we will refine, learning new facilities and approaches as 
  1024. we do so.
  1025.  
  1026. #  Move the easel so that the whole screen is empty.
  1027.  
  1028. #  Select bayesian item type.
  1029.  
  1030. #  The goals.  Lay down, to the right, boxes for three selection criteria:
  1031.  
  1032.       #  'High timber yield',
  1033.       #  'Hardy',
  1034.       #  'Good cover',
  1035.  
  1036. with meanings like:
  1037.  
  1038.       #  "It is important that trees have a good yield of timber",
  1039.       #  "It is important that trees are hardy and can stand vandalism",
  1040.       #  "It is important that trees provide good ground cover for wildlife
  1041.       and game."
  1042.  
  1043. These are our three criterion for selection of tree species.  Click the 
  1044. Show Value box for each so that we can see easily the importance of each 
  1045. criterion.
  1046.  
  1047. (Tip:  Might be useful to shorten the meanings so that more than the common 
  1048. part ("It is important that trees") appear in the mouse-position window. 
  1049. For instance, make the meanings like "Trees must have a good yield of 
  1050. timber.")
  1051.  
  1052. #  Over the left hand side, place boxes to represent the requirements of 
  1053. the user:
  1054.  
  1055.       #  'Financial return'
  1056.       #  'Timber'
  1057.       #  'Wildlife'
  1058.       #  'Near housing'
  1059.  
  1060. with meanings:
  1061.  
  1062.       #  "Planting is for financial reasons"
  1063.       #  "The income is to be from timber"
  1064.       #  "The planting should be good for wildlife"
  1065.       #  "The planting is near housing".
  1066.  
  1067. Notice that 'Near housing' is part of (b) above, while the others are part 
  1068. of (a).
  1069.  
  1070. #  In the middle, place a box:
  1071.  
  1072.       #  'Game'
  1073.  
  1074. with the meaning:
  1075.  
  1076.       #  "The planting should support game".
  1077.  
  1078. #  Link 'Financial return' to both 'High timber yield' and 'Game', because 
  1079. a money can be made either out of timber or game (pheasant shooting, etc.).
  1080.  
  1081. #  Link 'Timber' to 'High timber yield' with a positive link and to 'Game' 
  1082. with a negative link.  This means that if they don't want timber but do 
  1083. want a financial yield then it must be through game.
  1084.  
  1085. #  Link both 'Wildlife' and 'Game' to 'Good cover'.  Both require good 
  1086. cover.
  1087.  
  1088. #  Link 'Housing nearby' to 'Hardy'.  This is because if there is housing 
  1089. nearby then children etc. will visit the wood and are likely to do some 
  1090. damage to the trees, so they must be hardy.
  1091.  
  1092. #  Now clear the goal list and put the three right hand criteria into it. 
  1093. (See above for how to do this if you've forgotten.)
  1094.  
  1095. #  Run it (ResetGoals, InferGoals on KB panel).  That is our basic tree 
  1096. selector KB.
  1097.  
  1098. #  (Its results show how much importance should be attached to each 
  1099. criterion when assessing each tree species.  Normally (i.e. apart from 
  1100. what-iffing) the KB would be run once to obtain such importances and then 
  1101. these would be applied to the data for all the tree species.  The algorithm 
  1102. for applying criterion weights to data will depend on need and data 
  1103. available, but might consist of multiplying each degree of importance by 
  1104. the appropriate data and adding together.  For instance, if 'Hardy' turns 
  1105. out to be high (90%) and 'High timber yield' low (10%), then a tree with a 
  1106. hardiness factor of 8 out of 10 and a yield factor of 2 out of 10 the total 
  1107. would be 8 * 90% + 2 * 10% = 7.2 + 0.2 = 7.4.  For a tree with a hardiness 
  1108. factor of 2 and a yield factor of 8 the result would be 2 * 90% + 8 * 10% = 
  1109. 1.8 + 0.8 = 2.6.  So the former tree species would be preferred.  If 
  1110. running the KB had resulted in the opposite weights being given then the 
  1111. tree preferences would be reversed.)
  1112.  
  1113. #  This KB demonstrates basically how to set up this type of selector: have 
  1114. a group of items that represent the selection criteria, a group that 
  1115. represent the user requirements and a group that represent the common 
  1116. situation, and link them together.
  1117.  
  1118. #  Did you notice that even if you said you did not want a financial return 
  1119. it still asked you whether the income should be from timber or not.  (If 
  1120. you didn't notice it, run it again, answering -100 to 'Financial return'.) 
  1121. This is obviously not right.  So we will use a couple of facilities of 
  1122. Istar to amend it.
  1123.  
  1124. #  First, if the demand for financial return is low then there is little 
  1125. point in asking about 'Timber'.  Istar offers a cut-off on bayesians; you 
  1126. might have noticed the two gadgets on the bayesian attribute detail panel 
  1127. called LCO and UCO.  These are lower and upper cut-off, and when zero they 
  1128. are ignored.  But when not zero they come into play.  Take the lower cut-
  1129. off, LCO.  If LCO is 30% then as soon as it is certain that the probability 
  1130. value of the attribute cannot exceed 30% then the attribute is considered 
  1131. answered and no more of its antecedents are sought by backward chaining. 
  1132. This can be used to stop questions about 'Timber' when it is known that 
  1133. there is no financial interest.  Conversely with the upper cut-off, UCO.
  1134.  
  1135. #  Set the LCO of 'High yield' to 30%.
  1136.  
  1137. #  To use the cut-offs effectively we need to alter the weights of 
  1138. evidence.  So far we have used mild weights of 3/1 and 1/3, symmetrical 
  1139. about unity.  We need to give the link a strong asymmetry to pull the 
  1140. consequent down to near zero when the antecedent ('Financial return') is 
  1141. low.  Then, whatever value the other antecedent takes it will never rise 
  1142. above the LCO and so they will not be asked.  (For an understanding of 
  1143. weights, see the section in <Inference> on bayesians.)
  1144.  
  1145. #  Bring up the relationship instance panel for the link between 'Financial 
  1146. return' and 'High yield'.  It has four integers in four boxes called 
  1147. 'Weight', and they should be 3/1 and 1/3.  Set the fourth box to 30 rather 
  1148. than 3.  (Also, ensure that the unary operator is 'Normal', not 'Negate'.)
  1149.  
  1150. #  Now run the KB from just 'High yield' and answer 'Financial return' with 
  1151. -100.  It should now not ask about 'Timber'.  (If it does, perhaps you have 
  1152. run it by clicking Reset Goals and Infer Goals, because 'Timber' is still 
  1153. needed for 'Game', or perhaps you have not set the LCO of 'High yield' to 
  1154. 30%.)
  1155.  
  1156. #  To stop bayesian questioning we must therefore do two things: set the 
  1157. LCO (or occasionally the UCO) and set the weights on the link from the 
  1158. controlling antecedent.  So we must also do this for 'Game'.  Set its LCO 
  1159. also to 30% and set the weight on the link between 'Financial return' and 
  1160. 'Game' to 3/1, 1/30.  Then, when we ResetGoals and InferGoals, 'Timber' 
  1161. should only be asked if the 'Financial return' is answered more positively 
  1162. than about -30.
  1163.  
  1164. #  To summarize, in this section we have:
  1165.  
  1166.       #  Built a KB to assign weights to selection criteria
  1167.       #  .. which can then be applied to a database of options
  1168.       #  Recognised some different classes of information
  1169.       #  Found one way of preventing irrelevant questions being asked
  1170.       #  .. by employing lower (or upper) cut-off on a bayesian
  1171.       #  .. and by setting the weight of evidence on a link.
  1172.  
  1173.  
  1174. 10.  DEPENDENT ATTRIBUTES - IRRELEVANT QUESTIONS
  1175.  
  1176. It often happens that one attribute is a sub-type of another, or is somehow 
  1177. dependent on it, so that if the other is answered false then the dependent 
  1178. attribute is no longer applicable.  In the example above, 'High timber 
  1179. yield' is dependent on 'Financial return' in this way: if the user does not 
  1180. want a financial return then high timber yield becomes irrelevant, 'not 
  1181. applicable'.  When this happens, it is inappropriate to ask questions that 
  1182. solely establish the value of the dependent attribute; we need to suppress 
  1183. such irrelevant questions.
  1184.  
  1185.       In the above example we did this by means of the Lower Cut Off.  But
  1186. this is specific to Bayesian attributes.  There are two other methods.  The 
  1187. second method works only with booleans and an AND inference method.  The 
  1188. third, the most general, is only available in version 1.04 and later, and 
  1189. works with any consequent though it requires a boolean antecedent.
  1190.  
  1191. #  Preventing irrelevant questions by boolean AND.  Change the attribute 
  1192. type of 'Financial Return' and of 'High timber yield' to boolean (bring up 
  1193. attribute details panel for each and alter the type gadget).  Also alter 
  1194. the inference method of 'High timber yield' to 'A & B & ..'.  Ensure that 
  1195. 'Financial return' is the first antecedent of 'High timber yield'.  Run it 
  1196. several times.  When you answer 'Financial return' with 'No' it should not 
  1197. ask about 'Timber'; when you answer 'Yes' it should.
  1198.  
  1199. #  Using the CONTROL Unary Operator (Version 1.04 onwards).  Change 'High 
  1200. timber yield' back to a Bayesian attribute and its inference method back to 
  1201. Bayesian.  Turn off the Lower Cut Off, if active, by dragging it back to 
  1202. zero.  Keep 'Financial return' as boolean.  Now bring up the relationship 
  1203. details panel for the link between them, and change its Unary Operator to 
  1204. 'CONTROL'.  Now run the KB.  Answering 'Financial return' with 'No' should 
  1205. set the consequent of the CONTROL link ('Timber') to answered and 
  1206. (probably) unknown and thus suppress any further attempts to find its 
  1207. value.  When you answer with 'Yes' its value will be sought in the normal 
  1208. way.  This method will work with any type of consequent.
  1209.  
  1210.       To see the usefulness of the CONTROL unary operator, try the
  1211. following without it.  The cost of a house includes a number of optional 
  1212. factors, such as a conservatory.  If the conservatory is wanted, then its 
  1213. cost needs to be worked out (e.g. from its size and quality) and added to 
  1214. that of the house.  But if not wanted, then don't bother asking size and 
  1215. quality of conservatory, and don't add it to the cost of the house.  Using 
  1216. the CONTROL unary operator, we simply link 'Want Conservatory' to 
  1217. 'Conservatory cost'.  Without it, the latter will probably have to employ a 
  1218. Chooser, to choose between zero and a worked out cost.  While not a 
  1219. complicated thing to do, it nevertheless complicates the KB diagram by at 
  1220. least two extra superfluous attributes, and if there are many such 
  1221. instances, the whole loses its clarity.
  1222.  
  1223.  
  1224. 11.  CAUSAL MODELS
  1225.  
  1226. Istar can be used to built certain types of causal model.  A causal model 
  1227. tries to express what happens in some limited area of activity, such as 
  1228. machinery, electronics, biological systems, the weather, social systems, 
  1229. history and many more.  Some are deterministic, some normative (that is, 
  1230. there are laws that pertain but entities are not forced to obey them). 
  1231. With a causal model we can predict what will happen, and a major use is 
  1232. simulation (e.g. simulate the weather, or simulate an electronic circuit to 
  1233. see whether it will malfunction, or simulate social development).
  1234.  
  1235.       The more normative, the more 'fuzzy' the information about them and
  1236. less accurately can we predict or simulate.  Determinative models can often 
  1237. make use of numeric and boolean information while bayesians and 
  1238. probabilities are more useful for normative models.
  1239.  
  1240.       As you might have realised, the predictive KB above was a simple kind
  1241. of causal model.  The causality was economic and logical in nature rather 
  1242. than physical, and perhaps social and ethical, but it was still a valid 
  1243. kind of causality.  There are grounds in philosophy for seeing logical 
  1244. entailment as a form of causality.  In the same way evaluation and 
  1245. selection can involve causality.  That is why the same KB could be used, 
  1246. with minor alterations, for all these purposes.
  1247.  
  1248.       But there one purpose of a KB that does not normally make use of a
  1249. causal model - diagnosis.
  1250.  
  1251.  
  1252. 12.  DIAGNOSING WHY IT WENT WRONG OR RIGHT
  1253.  
  1254. Diagnosis is finding out what went wrong.  Or, more generally, what some 
  1255. initial state was that resulted in the observed final state.
  1256.  
  1257.       In most of the uses for KBs we have looked at so far (evaluation,
  1258. understanding, prediction, etc.) the inference has followed and modelled 
  1259. the causality, so that input information is of some initial state or cause 
  1260. and output information is of an outcome.  But in diagnosis inference and 
  1261. causality flow in opposite directions, so that input information is of the 
  1262. outcome and output information is about the initial state or cause.  This 
  1263. gives a diagnostic KB a different flavour, though it employs exactly the 
  1264. same inference mechanisms.
  1265.  
  1266.       We will construct a small KB that seeks to explain why a certain
  1267. company share did not give us good profits, why it went down in value when 
  1268. we expected it to go up.
  1269.  
  1270.       First, note that the causal KB we have used so far could in principle
  1271. be used for diagnosis.  To do so we would try all combinations of input 
  1272. information and see which ones gave the state we now observe of an 
  1273. unattractive share.  (Try it if you like: run it several times and see 
  1274. which combinations give low belief that we should 'Buy it'.)  But there are 
  1275. two problems:
  1276.  
  1277.       a)  it is cumbersome and time consuming (many combinations)
  1278.  
  1279.       b)  it cannot be very specific, in that there are several reasons why
  1280.       we are not advised to 'Buy it', and we do not know which was the one
  1281.       that functioned in this instance.
  1282.  
  1283.       So we need to build a different type of KB, in which the goal
  1284. attributes on the right hand side are such things as 'Was not strong 
  1285. sector', 'Management had no vision', etc. and the input information on the 
  1286. left hand side includes what was our goal above (negated) 'Should not have 
  1287. bought it' and other information which we have not represented above.
  1288.  
  1289. #  The first thing we can do is to try reversing the KB we have.  Load 
  1290. 'R1'.  Rather than reverse the actual KB we will create another below it, 
  1291. reversed.  Move the easel down so there is space below it but so that the 
  1292. original KB can be seen.  Squash some of its items up a bit to make room 
  1293. (and also to ensure that the main easel is active).
  1294.  
  1295. #  Move the mouse over 'Buy it' and press the 'T' key.  This selects item 
  1296. type to be the same type as the one under the mouse.  It's usually more 
  1297. convenient than using the select item type panel, and here we will make 
  1298. good use of it.
  1299.  
  1300. #  Place an item to the left hand side, corresponding to 'Buy it', but 
  1301. label it something like 'ShdNotHaveBought' with meaning like "We should not 
  1302. have bought this share".
  1303.  
  1304. #  Now select the type for 'Will' using the 'T' key, and place a box to the 
  1305. right of 'ShdNotHaveBought' and above, labelled 'DidNotGrow' with suitable 
  1306. meaning.  (Of course, in this KB most items are free bayesians, so strictly 
  1307. we don't have to keep using the 'T' key.  But it is a good habit to get 
  1308. into.)
  1309.  
  1310. #  Do similarly for 'More Profits', perhaps labelling it 'ProfitsFell'.
  1311.  
  1312. #  (Tip:  Notice the different style of labelling, without spaces; because 
  1313. the labels seem to be longer, but it could be useful as a visual way of 
  1314. distinguishing between casual and diagnostic knowledge.)
  1315.  
  1316. #  Link 'ShdNotHaveBought' as antecedent to both these.  (Note: antecedence 
  1317. and consequence is reversed.)
  1318.  
  1319. #  Then do similarly for all other items/attributes in the original KB, 
  1320. creating one below it that is the mirror image of it.
  1321.  
  1322. #  Now, what do you notice about this KB?  It has only one input variable, 
  1323. from which all the others are derived.  So, however it is answered, there 
  1324. will be no real way of distinguishing between what are now the inference 
  1325. goals.  We cannot tell whether it was lack of vision or weakness of the 
  1326. sector or any other factor that meant the shares did not do well.  We must 
  1327. add some further information to help us do so.
  1328.  
  1329. #  One way to do this is to focus on one of the factors that could have 
  1330. been a cause, such as 'SectorWasWeak' and ask "What else would weakness in 
  1331. the sector have led to?"  For instance, if the sector as a whole was weak 
  1332. then other firms in that sector would also have been weak.  So, if other 
  1333. firms also did badly then this is evidence that sector weakness was the 
  1334. problem, but if other firms did well then this is unlikely to have been the 
  1335. problem.
  1336.  
  1337. #  Add a bayesian 'OthersDidBadlyToo' as antecedent of 'SectorWasWeak'.
  1338.  
  1339. #  Maybe you also want to set the LCO of 'SectorWasWeak' then on its 
  1340. attribute list select 'DidNotGrow' and click the 'R' button to bring up the 
  1341. relationship instance panel.  Set the fourth weight figure to 60.  This 
  1342. will prevent 'OthersDidBadlyToo' from being asked if in fact the company 
  1343. did grow.
  1344.  
  1345. #  In the same way, ask "What else would have happened if the company did 
  1346. not grow?"  e.g. The turnover would have stayed the same, or the number of 
  1347. employees would have stayed the same or reduced.  Take one or both of these 
  1348. as evidence for 'DidNotGrow' in the same way.
  1349.  
  1350. #  Note that instead of asking about belief in the negative statement 
  1351. 'TurnoverDidNotIncrease' you could ask the positive statement 
  1352. 'TurnoverIncreased' and link it to 'DidNotGrow' as negative evidence (that 
  1353. is, with a unary operator of Negate).  You will come across many situations 
  1354. where it might be better to reverse a proposition and thus all its 
  1355. relationship (both antecedent and consequent).
  1356.  
  1357. #  (Knowledge refinement:  Instead of asking about turnover and employees 
  1358. separately, perhaps what we want is simply to ask "Did the company in fact 
  1359. grow during this period?")
  1360.  
  1361. #  In the same way, asking "What else could xxx have led to?", and linking 
  1362. what you come up with as antecedence for xxx, you can build a diagnostic 
  1363. KB.  Be sensitive to the possibility that one of these factors might be 
  1364. caused by several factors in your KB, in which case it should be linked as 
  1365. antecedent to them all.
  1366.  
  1367. #  To summarize, in this section we have:
  1368.  
  1369.       #  Noted the different nature of diagnostic knowledge.
  1370.       #  Reversed a KB.
  1371.       #  Used the quick same type facility ('T' key)
  1372.       #  Enriched our KB using the What else question.
  1373.       #  Noted that it might be useful to reverse a proposition.
  1374.  
  1375.  
  1376.  
  1377. 13.  MAKING YOUR KB MORE ACCURATE
  1378.  
  1379. So far most of the links in your KB have had the same weight and the a-
  1380. priori settings have remained at 50%.  This is obviously not true to real 
  1381. life.  Some factors are more important than others.  In this section we 
  1382. start to tailor some of the weights (strengths) of links and set the a-
  1383. priori probabilities of your bayesian attributes.
  1384.  
  1385. #  The a-priori probability is the foundation of bayesian evidence.  It 
  1386. forms the base point, to which to add evidence as it is collected.  It is 
  1387. the starting belief in the proposition represented by the bayesian, the 
  1388. belief you would have in it if you could obtain no evidence one way or 
  1389. another.  Usually the a-priori is the statistical probability of the 
  1390. proposition being true for the class of situations in which you will use 
  1391. the KB.
  1392.  
  1393. #  Load the 'R1' KB that you saved earlier.
  1394.  
  1395. #  Bring up the 'Buy it' attribute details panel.  Given 100 different 
  1396. companies, on average, for how many of them would you consider their shares 
  1397. attractive?  10%?  30%?  50%?  70%?  Suppose your answer were 20%, then 
  1398. find the 'AP' slider gadget to the right of the main value and move it to 
  1399. 20.  You have set the a-priori.
  1400.  
  1401. #  Now ask yourself the equivalent question ("Given 100 different 
  1402. companies, on average how many of them will grow?" etc.) for all other 
  1403. bayesians in the KB, and adjust their a-prioris to suit.
  1404.  
  1405. #  It's basically a simple operation to set the a-priori and with a little 
  1406. practice it becomes almost second nature.  But there can be difficulties, 
  1407. especially when you start off.
  1408.  
  1409. #  One is that you start to think, "Well, it depends ..."  On what?  One is 
  1410. that it might depend on sector.  If you can identify a factor on which this 
  1411. average depends then that factor is actually a piece of evidence that 
  1412. should be incorporated into your KB.  It depends on sector?  Then make the 
  1413. influence of sector a piece of evidence, and then you change your a-priori 
  1414. question to "Given 100 companies, when I take the average across all 
  1415. sectors, how many of them ...?"
  1416.  
  1417. #  (Notice how asking the a-priori question sometimes helps in knowledge 
  1418. refinement by forcing hidden influences out into the open.  But, in this 
  1419. case, you already have a 'Strong Sector' attribute.)
  1420.  
  1421. #  'Will grow' depends on sector, and that is already taken care of, via 
  1422. the item 'Strong sector'.  But perhaps 'Vision for growth' also depends on 
  1423. sector, in that in certain sectors the culture of that sector is for growth 
  1424. while in others it is not.  The I.T. sector tends to have a growth culture 
  1425. while the agricultural sector might not.  The construction industry at 
  1426. present is still in recession.  The sports sector seems to have a culture 
  1427. of growing.  So let us take these four as an example.  We will employ yet 
  1428. another facility of Istar, the Chooser inference method.
  1429.  
  1430. #  What we want is a piece of evidence for 'Vision for growth' that depends 
  1431. on sector.  Place a bayesian 'Sector vision' as antecedent to it.  Bring up 
  1432. its attribute details panel and change its inference method to Chooser. 
  1433. The Chooser takes an integer (or an Enum or Ordinal) as its first 
  1434. antecedent, and then all the others should normally be the same type as the 
  1435. consequent.  The Chooser first finds the value of the first antecedent. 
  1436. Then, if 1, it takes the first of the rest (i.e. the second antecedent), if 
  1437. 2 it takes the 2nd of the rest, and so on, and copies its value into the 
  1438. consequent.  In this case the attributes from which it chooses will be 
  1439. sector constants.
  1440.  
  1441. #  Select Integer item type and place an integer attribute as antecedent to 
  1442. 'Sector vision'.  Label is 'Sector Id' with meaning "The identifier for the 
  1443. sector".  Give it a question text of "To which sector does the company 
  1444. belong?  1 = I.T., 2 = Agriculture, 3 = Construction, 4 = Sports".  (For a 
  1445. less clumsy method than this long question, see Enumerated Types below.)
  1446.  
  1447. #  Now create four bayesian attributes as antecedents to 'Sector vision' 
  1448. and, by bringing up their attribute panels, make each a Constant.  Then 
  1449. give each a name and value something like:
  1450.  
  1451.       'I.T. vision'  90%
  1452.       'Agriculture vision'  10%
  1453.       'Construction vision' 20%
  1454.       'Sports vision' 60%
  1455.  
  1456. Try resetting and inferring 'Sector vision' to see what you obtain with 
  1457. different values of the Id.
  1458.  
  1459. #  (If you wish, you could also change 'Strong sector' from being an input 
  1460. information to a Chooser controlled by 'Sector Id' and to take its value 
  1461. from a similar bank of constants.  Then, by answering 'Sector Id', the user 
  1462. would automatically supply values to both 'Strong sector' and 'Sector 
  1463. vision'.)
  1464.  
  1465. #  Now, don't forget to set the a-priori for 'Vision for growth' as an 
  1466. average across all sectors.  If you expect about the same number of 
  1467. companies in each sector then you could just take the average of the 
  1468. sectors you are dealing with (90+10+20+60/4=45%).  The a-priori for 'Sector 
  1469. vision' can stay at 50% since it is merely a modifying factor.
  1470.  
  1471. #  (Tip:  Don't worry too much about accuracy of a-prioris or weights; they 
  1472. are more tolerant than you might think.)
  1473.  
  1474. #  We have dealt with a-prioris.  Now to deal with weights of evidence.  We 
  1475. will take as an example the item 'Will grow' and its antecedents 'Strong 
  1476. sector' and 'Vision for growth'.  In doing so we deal with odds rather than 
  1477. probabilities.  Odds and probabilities are linked as:
  1478.  
  1479.       O = P / (1 - P)
  1480.  
  1481. and
  1482.  
  1483.       P = O / (1 + O).
  1484.  
  1485. In Istar odds are held as two integers, numerator and denominator.
  1486.  
  1487. #  Let us suppose you have set the a-priori for 'Will grow' to 25%.  Its 
  1488. odds are therefore 0.25 / (1 - 0.25) = 0.25 / 0.75 = 1/3 ("one to three 
  1489. against").
  1490.  
  1491. #  For each antecedent we ask two questions:
  1492.  
  1493.       QT:  "Suppose we know that the antecedent is completely true; then
  1494.       what would the belief in the consequent be?" and
  1495.  
  1496.       QF:  "Suppose we know that the antecedent is completely false; then
  1497.       what would the belief in the consequent be?"
  1498.  
  1499. Ask them of 'Strong sector':  "Suppose we know for certain that it is a 
  1500. strong sector; what would our belief in 'Will grow' be?"  and conversely. 
  1501. Suppose we find QT gives 75% (odds = 3/1) and QF gives 10% (odds = 1/9).
  1502.  
  1503. #  This gives us the means to work out the weights on the link between 
  1504. them.  QT provides the left hand pair of numbers on the relationship 
  1505. instance panel, and QF the right hand.  Bring up the panel.
  1506.  
  1507. #  Each pair is an odds multiplier, such that when multiplied into the a-
  1508. priori odds of the consequent gives the answer to QT and QF respectively. 
  1509. Take the left hand pair and QT.
  1510.  
  1511.       A-priori odds of 'Will grow' = 1/3.
  1512.       Answer to QT = 3/1.
  1513.       Therefore odds multiplier must be 9/1.
  1514.  
  1515. So alter the left hand pair to 9/1.
  1516.  
  1517. #  In a similar way, the right hand pair and QF:
  1518.  
  1519.       A-priori odds of 'Will grow' = 1/3.
  1520.       Answer to QF = 1/9.
  1521.       Therefore odds multiplier must be 1/3 (which it already is).
  1522.  
  1523. Click on the 'OK' button.
  1524.  
  1525. #  Now process the others link weights in a similar manner:
  1526.  
  1527.       #  Convert the a-priori of the consequent to odds.
  1528.       #  Ask QT for the antecedent and consequent.
  1529.       #  Convert the answer to odds.
  1530.       #  Alter the left hand odds multiplier as appropriate.
  1531.       #  Ask GF and convert the answer to odds.
  1532.       #  Alter the right hand odds multiplier as appropriate.
  1533.  
  1534. #  Save the KB as 'R2'.
  1535.  
  1536. #  Now run the KB.  You should start to find the results are more 
  1537. meaningful and interesting than before.  (NOTE:  At present there is a wee 
  1538. bug in the Chooser, in not resetting its antecedents.  To overcome this, 
  1539. you might have to press Reset a couple of times.)
  1540.  
  1541. #  To summarize, in the section we have:
  1542.  
  1543.       #  Concerned ourselves with KB accuracy.
  1544.       #  Met with a-priori probabilities for bayesians
  1545.       #  Found a simple question to ask to calculate them.
  1546.       #  Noted that this can unearth other factors.
  1547.       #  Used the Chooser.
  1548.       #  Set the weights of evidence ..
  1549.       #  .. by using odds and two simple questions.
  1550.  
  1551.  
  1552.  
  1553. 14.  MAKING YOUR KBS MORE USABLE
  1554.  
  1555. In this section we note some ways to make the KB more usable, easier to 
  1556. use, more friendly to the user.
  1557.  
  1558. #  Enumerators
  1559.  
  1560. The Chooser was driven by an integer, which meant the question text had to 
  1561. be cumbersome.  A more serious problem was that the user was free to enter 
  1562. any value.  Future versions of Istar might have value checking on input for 
  1563. integers etc. but a better method is available now: use an Enumerated Type.
  1564.  
  1565.       An enumerated type is an identifier of which option is selected from
  1566. a set, e.g. which business sector.  One is already available as standard: 
  1567. Weekdays.  But we must create another.
  1568.  
  1569. #  Load 'R2' if not already up.
  1570. #  On main control panel, click the Atts button.
  1571. #  (See Driving section on Creating New Attributes for details.)
  1572. #  Add a new attribute whose name is 'Sector' and whose type is Enumerated.
  1573. #  Remember to click the left Add button.
  1574. #  On the right hand side, enter in the 'N' gadget "I.T." and click Add.
  1575. #  Enter "Agriculture" and click Add.
  1576. #  Enter "Construction" and click Add.
  1577. #  Enter "Sports" and click Add.
  1578. #  Click Done.
  1579. #  Bring up the attribute details panel for 'Sector Id'.  Click the value 
  1580. type wee button to bring up list of attribute types.  Select 'Sector'. 
  1581. Click 'OK' on the type list.
  1582. #  Now click 'OK' on the attribute details panel.
  1583. #  Reset/infer 'Sector vision' and you should find it will no longer ask 
  1584. you for an integer but give you a cycle gadget showing the sector names.
  1585. #  Now you can change the question text for 'Sector Id' to suit.
  1586.  
  1587.       It is often useful to create Enumerated types for the major
  1588. identifiers your KB uses.  Some will be Enums, some Ordinals.  Ordinals 
  1589. differ from Enums in that the options are in some numeric order rather than 
  1590. being just options.  e.g. Low, medium and high.
  1591.  
  1592.  
  1593. #  The order in which questions are asked
  1594.  
  1595. The order in which questions are asked is seldom important to the final 
  1596. results given by a KB but can make a lot of difference to the user.  For 
  1597. instance it is sensible to have the major questions at the start and also 
  1598. to try to put questions relating to a given topic together.  The order in 
  1599. which they are asked depends on the backward chaining process, the 
  1600. inference methods employed and the answers to previous questions.  But 
  1601. there are several ways of controlling the order of asking.
  1602.  
  1603. #  By altering the order of antecedents of an inference attribute.
  1604. #  By understanding the order imposed by certain inference methods.  For 
  1605. instance, in Chooser the first antecedent must be completely asked and 
  1606. answered before any of the others are sought, so all the questions that 
  1607. pertain to the first will be asked first.  Similarly, in the comparison 
  1608. methods (A > the rest, etc.) the first must be asked first.
  1609.  
  1610.  
  1611. #  Suppressing irrelevant questions
  1612.  
  1613. Often certain questions are irrelevant to the flow of the run of a KB.  For 
  1614. instance for the I.T. sector it is irrelvant to ask about farming 
  1615. practices.  There are various ways to prevent irrelevant questions being 
  1616. asked.
  1617.  
  1618. #  The Chooser.  This will backward chain only up the chosen route and will 
  1619. ignore the others.
  1620. #  Bayesian cut-offs.  Setting these will stop seeking input once it is 
  1621. certain that the value of the bayesian attribute either cannot exceed the 
  1622. lower cut-off or cannot be less than the upper cut-off, however the 
  1623. remaining unanswered antecedents are answered.
  1624. #  Certain arithmetic and logical inference methods stop when an extreme 
  1625. answer is known.  e.g. the process stops when: one of the antecedents is 
  1626. zero in multiplication, when one is false in boolean AND, when one is true 
  1627. in boolean OR.
  1628. #  In the comparisons that give a boolean result, as soon as the comparison 
  1629. fails the process stops.  So "A > the rest" will stop as soon as one of the 
  1630. rest is found to be >= A.
  1631.  
  1632.  
  1633. #  Forms
  1634.  
  1635. The normal method of obtaining information when running a KB in Istar is 
  1636. question by question, since that allows the session to be most responsive 
  1637. to the way information given.  But sometimes it is useful to have several 
  1638. related pieces of information all on the same screen.
  1639.  
  1640.       For this, Istar offers a simple 'Forms' facility.
  1641.  
  1642. #  (Load a KB, such as R1.)
  1643. #  Select 'Form' item type.
  1644. #  Place an item of this type to the left of a number of attributes on your 
  1645. KB.  Notice it has no name (though it can be given one).
  1646. #  Then, draw a link from the Form item to one of the attributes.
  1647. #  Then to another, and another.
  1648. #  Run the whole KB.  You should find that the three attributes you have 
  1649. linked to the form are all presented on a single screen.
  1650. #  Answer them all, and click 'OK'.
  1651. #  Allow the rest of the questions to be asked.
  1652. #  Now click with right mouse button on the form item, and up comes an item 
  1653. details panel.
  1654. #  Enter a name (label), some meaning.
  1655. #  Enter Form Text such as "Please give values for the following:".
  1656. #  Click 'OK'.
  1657. #  The label should now appear in the form box on the easel and the meaning 
  1658. appear in the window when you move the mouse over it, just as with 
  1659. attributes.
  1660. #  Run the KB and this time your Form Text should appear at the head of the 
  1661. form.
  1662.  
  1663.       This facility is as yet undeveloped; new versions should appear
  1664. later.
  1665.  
  1666.  
  1667. #  Requiring less detail of the user
  1668.  
  1669. As it stands, our KB will ask us two things about the quality of 
  1670. management.  As the KB develops we might find these split into several 
  1671. more, which can feel rather too detailed to the user.  For this reason it 
  1672. is sometimes useful to first ask a more general question about the overall 
  1673. quality of management and derive these other factors from that.  Then, only 
  1674. when detail is needed, ask these factors separately.
  1675.  
  1676.       There are several ways of doing this.  The easiest is to link all the
  1677. management factors back to 'Good management' as their single antecedent, 
  1678. and give weights accordingly.
  1679.  
  1680.       But that does not differentiate much: they will all rise and fall
  1681. together.  There are several ways to overcome this, such as have another 
  1682. item that asks whether the management's strengths are in marketing, 
  1683. production or finance, and sets the various factors accordingly.
  1684.  
  1685.  
  1686.  
  1687.  
  1688. Copyright (c) Andrew Basden, 1996
  1689.